<?php

declare(strict_types=1);

namespace App\Model\Orders;

use App\Model\Model;
use App\Traits\Model\Orders\OrderGood as OrderGoodTraits;

/**
 * @property int $id 
 * @property int $shop_id 店铺ID
 * @property int $order_id 订单ID
 * @property int $good_id 商品ID
 * @property array $good 商品内容
 * @property float $paid_price 付款单价
 * @property float $price 商品单价
 * @property float $preferential_price 商品优惠价
 * @property int $num 商品数量
 * @property string $sku 商品SKU
 * @property string $product_id 商品标识
 * @property string $good_no 商品编码
 * @property string $barcode 商品条码
 * @property int $shipment_status 发货状态|{"1":"未发货","2":"已发货","3":"已换货","4":"已退货"}
 * @property int $invoice_id 发货单
 * @property string $snapshot 快照
 * @property string $product_link 商品链接
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class OrderGood extends Model
{
    use OrderGoodTraits;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'order_good';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = [
        'id',
        'shop_id',
        'order_id',
        'good_id',
        'good',
        'paid_price',
        'price',
        'preferential_price',
        'num',
        'product_id',
        'sku',
        'good_no',
        'barcode',
        'shipment_status',
        'invoice_id',
        'snapshot',
        'product_link',
        'created_at',
        'updated_at'
    ];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = [
        'id' => 'integer',
        'shop_id' => 'integer',
        'order_id' => 'integer',
        'good_id' => 'integer',
        'paid_price' => 'decimal:2',
        'price' => 'decimal:2',
        'preferential_price' => 'decimal:2',
        'good' => 'array',
        'num' => 'integer',
        'shipment_status' => 'integer',
        'invoice_id' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    /**
     * 自动新增
     * @var array|string[]
     */
    public array $insert = [
        'shop_id'
    ];
}
